using System;
using System.Collections.Generic;
using System.Text;
using WozLib.WozObjects;
using System.Windows.Documents;
using WozLib.UI.Ink;
using System.Xml.Serialization;

namespace WOzTestUI.WozObjects
{
  public class ScratchWindowWozObject : ServerObject
  {

    [XmlElement("WozScreens")]
    public List<ScreenServerObject> WozScreens
    {
      get
      {
        if (_WozScreens.Count > 0)
        {
          return _WozScreens;
        }
        else if (ServerObjectRegistry.ContainsObject(this.ServerID) && 
          ServerObjectRegistry.GetObject(this.ServerID) is ScratchWindow)
        {
          List<ScreenServerObject> wozScreens = new List<ScreenServerObject>();

          ScratchWindow scratchWindow = ServerObjectRegistry.GetObject(this.ServerID) as ScratchWindow;

          foreach (WozScreen wozScreen in scratchWindow.WozScreens)
          {
            wozScreens.Add(wozScreen.GetServerObject() as ScreenServerObject);
          }


          return wozScreens;
        }
        else
        {
          return _WozScreens;
        }
      }
      set
      {
        _WozScreens = new List<ScreenServerObject>(value);
      }
    } private List<ScreenServerObject> _WozScreens = new List<ScreenServerObject>();

    public ScratchWindowWozObject()
    {
    }

    public ScratchWindowWozObject(long serverID)
      : base(serverID)
    {
    }

    // Doesn't do anything because ScratchWindow need to be instantied at application startup
    public override IServerObject GetIServerObject()
    {
      return null;
    }
  }
}
